﻿<%@ page title="" language="C#" masterpagefile="~/MasterPageMcSigAdmin.master" autoeventwireup="true" CodeFile="ContratacionListado.aspx.cs" inherits="ContratacionListado" %>

<%@ Register assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>

<%@ Register assembly="UsrControls" namespace="UsrControls" tagprefix="cc1" %>

<%@ Register assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView.Export" tagprefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script language="javascript">
     function confirmEditAspx() {
         var counter = ASPxGridViewContratosListado.GetSelectedRowCount();

         if (counter > 1) {
             counter = 0;
             alert("Debe seleccionar un solo registro");
             return (false);
         }
         else if (counter == 1) {
             counter = 0;
             return (true);
         }
         else if (counter == 0) {
             counter = 0;
             alert("Debe seleccionar al  menos un registro");
             return (false);
         }
     }
				
    </script>
    <table style="width:980px;">
    <tr>
    <td>
    <h1 class="contratos">Contratos</h1>
    </td>
    </tr>
    <tr>
    <td>
        <dx:ASPxButton ID="btnConsultaRapida" runat="server" 
            onclick="btnConsultaRapida_Click" Text="Consulta Rapida Contratos" 
            Theme="SoftOrange">
        </dx:ASPxButton>
</td>
    </tr>
    <tr>
    <td>
        <dx:ASPxButton ID="btnContrato" runat="server" onclick="btnContrato_Click" 
            Text="Contrato" Visible="False">
        </dx:ASPxButton>
    </td>
    </tr>
    <tr>
    <td>
        <dx:ASPxGridView ID="ASPxGridViewContratos" runat="server" 
            AutoGenerateColumns="False" DataSourceID="SqlDataSourceConsultaRapida" 
            EnableTheming="True" KeyFieldName="CTT_ID" Theme="PlasticBlue" Visible="False">
            <Columns>
                <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" 
                    Width="30px">
                    <ClearFilterButton Visible="True">
                    </ClearFilterButton>
                </dx:GridViewCommandColumn>
                <dx:GridViewDataTextColumn FieldName="CTT_ID" ReadOnly="True" VisibleIndex="1" 
                    Width="30px">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="NOMBRE" 
                    FieldName="CCO_NOMBRE" VisibleIndex="3" Width="200px">
                </dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="CCO_IDENTIFICACION" 
                    Caption="IDENTIFICACION" VisibleIndex="4" Width="150px"></dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="ABOGADO_ASIGNADO" VisibleIndex="5" 
                    Width="200px">
                </dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="ABOGADO_IMPRIME" 
                    VisibleIndex="6" Width="200px"></dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="VALOR CONTRATO" 
                    FieldName="CTT_VALOR_CONTRATO" VisibleIndex="7" Width="120px">
                    <PropertiesTextEdit DisplayFormatString="{0:N0}">
                        </PropertiesTextEdit>
                </dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="PLN_ANO" Caption="AÑO" 
                    VisibleIndex="8" Width="100px"></dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="OBJETO" FieldName="FAE_OBJETO" 
                    VisibleIndex="9" Width="250px">
                    <CellStyle Wrap="False">
                    </CellStyle>
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="RUBRO" FieldName="PLN_NOMBRE" 
                    VisibleIndex="10" Width="200px">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="ESTADO" FieldName="ESTADO" 
                    VisibleIndex="11" Width="100px">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="NUMERO EP" FieldName="FAE_NUMEROEPE" 
                    VisibleIndex="2" Width="60px">
                </dx:GridViewDataTextColumn>
            </Columns>
            <SettingsBehavior ColumnResizeMode="Control" />
            <Settings ShowFilterRow="True" ShowGroupPanel="True" ShowFilterRowMenu="True" />
        </dx:ASPxGridView>
        <asp:SqlDataSource ID="SqlDataSourceConsultaRapida" runat="server" 
            ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>" 
            SelectCommand="SELECT     CON_CONTRATACION.CTT_ID, CON_CONTRATISTAS.CCO_IDENTIFICACION, CON_CONTRATACION.CTT_VALOR_CONTRATO, SIG_PLAN_ACCION.PLN_ANO, 
                      FIN_ACCION_EPE.FAE_OBJETO, SIG_PLAN_ACCION.PLN_NOMBRE, 
                      CASE CON_CONTRATACION.TPE_ID WHEN 5 THEN 'PENDIENTE ELABORAR MINUTA' WHEN 8 THEN 'CONTRATO FINALIZADO' WHEN 0 THEN 'PENDIENTE INICIAR PROCESO'
                       END AS ESTADO, FIN_ACCION_EPE.FAE_NUMEROEPE, CON_CONTRATISTAS.CCO_NOMBRE, ADM_USUARIOS.USU_NOMBRE AS ABOGADO_IMPRIME,
                       
                       (
                       SELECT TOP 1 AU.USU_NOMBRE FROM 
                       dbo.ADM_PERMISOS_EPES APE INNER JOIN dbo.ADM_USUARIOS AU ON
                       APE.USU_ID = AU.USU_ID WHERE APE.TEP_ID = 5 
                       AND APE.USU_ID <> 241 AND APE.USU_ID <>  265 AND APE.PLN_ID =  SIG_PLAN_ACCION.PLN_ID 
                       ) AS ABOGADO_ASIGNADO
FROM         CON_CONTRATACION INNER JOIN
                      CON_CONTRATISTAS ON CON_CONTRATACION.CCO_ID = CON_CONTRATISTAS.CCO_ID INNER JOIN
                      CON_CONTRATACION_FIN_ACCION_EPE ON CON_CONTRATACION.CTT_ID = CON_CONTRATACION_FIN_ACCION_EPE.CTT_ID INNER JOIN
                      FIN_ACCION_EPE ON CON_CONTRATACION_FIN_ACCION_EPE.FAE_ID = FIN_ACCION_EPE.FAE_ID INNER JOIN
                      SIG_ACCION ON FIN_ACCION_EPE.ACC_ID = SIG_ACCION.ACC_ID INNER JOIN
                      SIG_PLAN_ACCION ON SIG_ACCION.PLN_ID = SIG_PLAN_ACCION.PLN_ID LEFT OUTER JOIN
                      ADM_USUARIOS ON CON_CONTRATACION.USU_ID_IMPRIME = ADM_USUARIOS.USU_ID
WHERE     (SIG_PLAN_ACCION.PLN_ANO = 2015)" 
            >
        </asp:SqlDataSource>
        <dx:ASPxGridViewExporter ID="ASPxGridViewExporter1" runat="server" 
            GridViewID="ASPxGridViewContratos">
        </dx:ASPxGridViewExporter>
        <dx:ASPxButton ID="btnExportarContratos" runat="server" 
            onclick="btnExportarContratos_Click" Text="Exportar" Visible="False">
        </dx:ASPxButton>
    </td>
    </tr>
        <tr>
            <td>
                <table style="width: 100%;">
                <tr>
            <td colspan="2">
               <p class="bt-space10">
                                <asp:Label ID="lblInstruccion" runat="server" Text="Para agregar o actualizar la informacion de Contratistas y Contratos, por favor sobre el boton Nuevo o Actualizar."
                                    CssClass="instruccion" Width="900px"></asp:Label>
                            </p>
                
            </td>
        </tr>
                    <tr>
                        <td width="10%" align="left">
                           <dx:ASPxButton ID="btnNuevo" runat="server" Text="Nuevo Contratista" 
                    Theme="SoftOrange" onclick="btnNuevo_Click">
                             </dx:ASPxButton>
 
                        </td>
                        <td align="left">
                            
                     <dx:ASPxButton ID="btnActualizar" runat="server" Text="Actualizar Contratista" 
                    onclick="btnActualizar_Click" Theme="SoftOrange">
                             </dx:ASPxButton>
                        </td>
                       
                    </tr>
                   
                </table>
               
                    
       
                <cc1:msgBox ID="msgBox1" runat="server" />
                </td>
        </tr>
        <tr>
            <td>
                <dx:ASPxGridView ID="ASPxGridViewContratosListado" ClientInstanceName="ASPxGridViewContratosListado" runat="server" AutoGenerateColumns="False" 
                    EnableTheming="True" Theme="PlasticBlue" KeyFieldName="CCO_ID">
                    <Columns>
                        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                            <ClearFilterButton Visible="True">
                            </ClearFilterButton>
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataTextColumn FieldName="CCO_ID" VisibleIndex="1">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="CCO_IDENTIFICACION" VisibleIndex="2">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="CCO_NOMBRE" VisibleIndex="3">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="CCO_COREO_ELECTRONICO" VisibleIndex="4">
                        </dx:GridViewDataTextColumn>
                        
                        <dx:GridViewDataTextColumn FieldName="CCO_DIRECCION" VisibleIndex="5">
                        </dx:GridViewDataTextColumn>
                        
                        <dx:GridViewDataTextColumn FieldName="CCO_TELEFONO_CELULAR" VisibleIndex="6">
                        </dx:GridViewDataTextColumn>
                        
                        <dx:GridViewDataTextColumn FieldName="CCO_PROFESION" VisibleIndex="7">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="Municipio" VisibleIndex="8">
                        </dx:GridViewDataTextColumn>

                        <dx:GridViewDataTextColumn FieldName="Departamento" VisibleIndex="9">
                        </dx:GridViewDataTextColumn>
                    </Columns>
                    <SettingsBehavior EnableCustomizationWindow="True" />
                    <Settings ShowFilterRow="True" ShowFilterBar="Visible" ShowFilterRowMenu="True" 
                        ShowFooter="True" ShowGroupPanel="True" ShowTitlePanel="True" />
                    <SettingsText Title="Contratistas" />
                    <SettingsCookies Enabled="True" />
                </dx:ASPxGridView>
            </td>
        </tr>
        <tr>
            <td>
                            
                     <dx:ASPxButton ID="btnExportar" runat="server" Text="Exportar" 
                    onclick="btnExportar_Click" Theme="SoftOrange">
                             </dx:ASPxButton>
                        <dx:ASPxGridViewExporter ID="gridExport" runat="server" 
                    GridViewID="ASPxGridViewContratosListado">
                </dx:ASPxGridViewExporter>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
        </tr>
    </table>
</asp:Content>

